package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.annotation.AutoFill;
import com.sky.dto.DishPageQueryDTO;
import com.sky.entity.Dish;
import com.sky.enumeration.OperationType;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface DishMapper {
    /**
     * 分页查询
     *
     * @param dishPageQueryDTO
     * @return
     */
    Page<Dish> pageDish(DishPageQueryDTO dishPageQueryDTO);


    /**
     * 插入菜品数据
     *
     * @param dish
     */
    @AutoFill(value = OperationType.INSERT)
    void insertDish(Dish dish);

    /**
     * 根据id查询Id是否存在
     * @param id
     * @return
     */
    @Select("select * from dish where id = #{id}")
    Dish getByDishId(Long id);


    /**
     * 根据id集合删除菜品
     * @param dishIds
     * @return
     */
    public int deleteDish(List<Long> dishIds);

    /**
     * 修改菜品状态
     * @param dish
     */
    @AutoFill(value = OperationType.UPDATE)
    @Update("update dish set status = #{status} where id = #{id}")
    void changeDishStatus(Dish dish);

    List<Dish> list(Dish dish);
}
